<?php
class My_Helper_Action_Gui extends Zend_Controller_Action_Helper_Abstract 
{
	public function setToolbar($commands,$title="",$icon = "t_icon_category.png")
	{
		$controller = $this->getRequest()->getControllerName();
		$module = $this->getRequest()->getModuleName();
		$action = $this->getRequest()->getActionName(); 
        
		if(is_array($commands))
		{
			$input['commands'] = $commands;
		}

		$input['icon'] = $icon;
		$input['title'] = $title;
		$input['controller'] = $controller;
		$input['module'] = $module;
		$input['baseURL'] = $this->_actionController->view->baseURL;
		
        $this->_actionController->view->layout()->toolbar = 
        $this->_actionController->view->partial("admin_toolbar.phtml", $input);
	}
	
	public function hideMenu()
	{
		$this->_actionController->view->hideMenu = true;
	}
	
 	public function showData($data, $size = 20)
    {
    	if(!empty($size))
    	{
	    	Zend_Paginator::setDefaultScrollingStyle('Sliding');
			Zend_View_Helper_PaginationControl
				::setDefaultViewPartial('paginator.phtml');
	    	$paginator = Zend_Paginator::factory($data);
	    	$page = $this->getRequest()->getParam('page');
			$paginator->setCurrentPageNumber($page);
			$paginator->setItemCountPerPage($size);
			$this->_actionController->view->data = $paginator;
			$this->_actionController->view->paginator = $paginator;
    	}
    	else{
    		if($data instanceof Zend_Db_Select)
    		{
    			$data = $data->query()->fetchAll();	
    		}
    		$this->_actionController->view->data = $data;
    	}
    }
	
}